/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

/**
 *
 * @author Alberto
 */
public class Email {
    private String nome;
    private String endereco;
    private String msg;

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
    
     public void enviaEmail(Email nEmail) throws EmailException {

        SimpleEmail email = new SimpleEmail();
        //email.setCharset("UTF-8");
        email.setHostName("smtp.gmail.com"); // o servidor SMTP para envio do e-mail  

        //email.setSSL(true);
        System.out.println("nome "+nEmail.getNome()+" endereço "+nEmail.getEndereco()+" mensagem "+nEmail.getMsg());
        email.addTo(nEmail.getEndereco(),nEmail.getNome());
       // email.setSslSmtpPort("587");
       // email.addTo("aajbeto@gmail.com", "Wakaba");
        email.setSubject("Contato sobre torneio Wakaba de: "+nEmail.getNome()+" "+nEmail.getEndereco()); // assunto do e-mail 
        email.setMsg(nEmail.getMsg()+"\n Responder para: "+nEmail.getNome()+" "+nEmail.getEndereco()); //conteudo do e-mail  
        //email.setFrom(nome, endereco);
        email.setFrom("4acessoftware@gmail.com"); // remetente 
        email.addReplyTo(nEmail.getEndereco(),nEmail.getNome());

        email.setAuthentication("4acessoftware@gmail.com","godinho2013");
        email.setSmtpPort(587);
      //  email.setSSLOnConnect(true);
       // email.setSSLCheckServerIdentity(true);
        email.setSSL(true);
        email.send();

    }
    
}
